﻿jQuery(function ($) {
    $("#uploadify_div").uploadify({
        debug: false,
        width: 80,
        height: 35,
        buttonText: "上传",
        swf: '/Admin/Uploadify/uploadify.swf',
        uploader: '/Admin/Uploadify/UploadifyUpload.ashx?columnName=' + $("#columnName").text(),
        //'auto': false,
        successTimeout: 99999,
        fileTypeDesc: '办公文件',
        fileTypeExts: '*.txt; *.zip; *.rar; *.pdf; *.doc;*.docx; *.xls; *.xslx; *.ppt; *.pptx;',
        fileSizeLimit: '100MB',
        //选择上传文件后调用
        onSelect: function (file) {
        },

        //返回一个错误，选择文件的时候触发
        'onSelectError': function (file, errorCode, errorMsg) {
            switch (errorCode) {
                case -100:
                    alert("the number of files must less than " + $('#uploadify_div').uploadify('settings', 'queueSizeLimit') + "!");
                    break;
                case -110:
                    alert("file [" + file.name + "] not in the range of" + $('#uploadify_div').uploadify('settings', 'fileSizeLimit') + "!");
                    break;
                case -120:
                    alert("file [" + file.name + "] size exception!");
                    break;
                case -130:
                    alert("file [" + file.name + "] type not allow!");
                    break;
            }
        },
        //检测FLASH失败调用
        'onFallback': function () {
            alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");
        },
        //上传到服务器，服务器返回相应信息到data里
        'onUploadSuccess': function (file, data, response) {
            //alert(data);
            $("#FileUrl").val(data);
            $("#FileType").val(file.type);
            $("#FileSize").val(file.size);
        }
    });
});